package com.snail.springjpa.demo;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.snail.springjpa.annotation.MyEnableAnnotation;
import lombok.SneakyThrows;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

import java.util.Map;
import java.util.Set;

/**
 * @title: DemoImportSelector
 * @Author liwenbo
 * @Date: 2021/8/25 17:14
 */
public class DemoImportSelector implements ImportSelector {
    @SneakyThrows
    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        Set<String> annotationTypes = importingClassMetadata.getAnnotationTypes();
        Map<String, Object> annotationAttributes = importingClassMetadata.getAnnotationAttributes(MyEnableAnnotation.class.getName());
        System.out.println(new ObjectMapper().writeValueAsString(annotationTypes));
        return new String[0];
    }
}
